﻿DKPMC = LibStub("AceAddon-3.0"):NewAddon("DKPManager Client", "AceConsole-3.0", "AceEvent-3.0", "AceSerializer-3.0","AceComm-3.0")


----------------------- file-scope variables used in several functions ----------------------- 
    local zKP_colsPlayerBidding = 1
    local zKP_colsBiddingAs     = 2
    local zKP_colsCurrentDKP    = 3 
    local zKP_colsBiddingSpec   = 4 
	local zKP_colsBidAMOUNT     = 5
    local zKP_highestBid        = 0
    local zKP_biggerThenHighestBid = false
    local zKP_greenColor = { ["r"] = 0.0, ["g"] = 1.0, ["b"] = 0.0, ["a"] = 1.0 } -- GREEN                
    local zKP_whiteColor = { ["r"] = 1.0, ["g"] = 1.0, ["b"] = 1.0, ["a"] = 1.0 } -- WHITE    

	local zKP_MainSpec	= "Main"
	local zKP_OffSpec	= "Off"
	local zKP_DualSpec	= "Dual"

    
    local zKP_biddersItems = {}
    local zKP_Client_Prefix                   = "zKP_Client"
    local zKP_Client_Prefix_bid_item_query    = "zKP_Client_bid_item_query"
    local zKP_Client_Prefix_bid_item_respond  = "zKP_Client_bid_item_respond"
	local zKP_Client_Prefix_ChangeBiddingSpec = "zKP_Client_ChangeBiddingSpec"
	local zKP_Client_Prefix_QueryBiddingSpec  = "zKP_Client_QueryBiddingSpec"
    
    local zKP_Server_Prefix                   = "zKP_Server"

    


	--The player name who is running this addon
    zKP_addonOwner, addonRealm = UnitName("player") 
    
    --[[If this variable evaluates = true 
        then debug information will be printed in the default chatframe window.]]
    local zKP_client_debugging = false
    
-----------------------------------------------------------
----------------- INITIALIZING METHODS --------------------
-----------------------------------------------------------


function DKPMC:OnInitialize()    -- General variables setup --



	if not (zKP_Client_Variables ) then
        zKP_Client_Variables    = {}
	end

		--options panel variables initialization
	if  not (zKP_Client_Variables.options ) then	
		zKP_Client_Variables.options = {}		
	end

	if not (zKP_Client_Variables.options.gui) then	
		zKP_Client_Variables.options.gui = {}
	end

	if not (zKP_Client_Variables.options.gui.showBidDialogInCombat) then	
		zKP_Client_Variables.options.gui.showBidDialogInCombat  = false
	end

	if not (zKP_Client_Variables.options.use_wl_engine ) then	
		zKP_Client_Variables.options.use_wl_engine = true
	end

	if not (zKP_Client_Variables.options.use_wl_timer  ) then	
		zKP_Client_Variables.options.use_wl_timer  = true
	end

	

		--gui variables initialization
	if not (zKP_Client_Variables.gui ) then	
		zKP_Client_Variables.gui = {}
	end
	
	
	if not (zKP_Client_Variables.gui.bidButton1 ) then	
		zKP_Client_Variables.gui.bidButton1 = "100"
	end
    
	if not (zKP_Client_Variables.gui.bidButton2 ) then	
		zKP_Client_Variables.gui.bidButton2 = "150"
	end
		
	if not (zKP_Client_Variables.gui.bidButton3 ) then	
		zKP_Client_Variables.gui.bidButton3 = "300"
	end
		
		
		

    zKP_Client_Variables.bidding             = false
    zKP_Client_Variables.savedBids           = {}
    zKP_Client_Variables.dkpList             = nil -- contains the ScrollingFrame used for listing the bidders
    zKP_Client_Variables.frame	             = nil -- contains the addon mainBiddingFrame Dialog
    
    zKP_Client_Variables.raidRoster          = {}
    
    -- DkpLeader setup --
    zKP_Client_Variables.DkpLeader           = {}
    zKP_Client_Variables.DkpLeader.name      = ""
    
    -- biddingList setup --
    zKP_Client_Variables.biddingList         = {}
    zKP_Client_Variables.biddingList.columns = {}
    zKP_Client_Variables.biddingList.data    = {}

	-- slash commands
    DKPMC:RegisterChatCommand("dkpclient", "SlashCommands")
    DKPMC:RegisterChatCommand("dkpc", "SlashCommands")


	
  	DKPMCopt:LoadOptions()
	DKPMCinitGui:Init()
end

function DKPMC:OnEnable()
	
	DKPMC:RegisterEvent("CHAT_MSG_WHISPER", "TimerEvent")

	-- Raid Event
	DKPMC:RegisterEvent("RAID_INSTANCE_WELCOME", "RaidEventHandler")
	DKPMC:RegisterEvent("RAID_ROSTER_UPDATE", "RaidEventHandler")

	-- Raid Chat event
	DKPMC:RegisterEvent("CHAT_MSG_RAID_WARNING", "BiddingEvent")  
	DKPMC:RegisterEvent("CHAT_MSG_RAID_LEADER", "BiddingEvent")
	DKPMC:RegisterEvent("CHAT_MSG_RAID", "BiddingEvent")
		
	-- Register ADDON communication prefixes
	DKPMC:RegisterComm(zKP_Server_Prefix, "Server_Client_Syncronization")
	DKPMC:RegisterComm(zKP_Client_Prefix_bid_item_query, "RespondToOtherBiddersItemRequest")
	DKPMC:RegisterComm(zKP_Client_Prefix_bid_item_respond, "BiddersItemDataReceived")
	DKPMC:RegisterComm(zKP_Client_Prefix_ChangeBiddingSpec, "BidderChangingBiddingSpec")

end


function DKPMC:OnDisable()   
end

    
---------------------------------------------------------------        
------------------------ MISC functions -----------------------
---------------------------------------------------------------

function DKPMC:SlashCommands(input)
	DKPMC:InitializeBiddingFrame("|cff9d9d9d|Hitem:7073:0:0:0:0:0:0:0|h[Sambasvamp]|h|r up for bids.")
        getglobal("DKP_QueryList"):Show()
end

function DKPMC:Debug(msg)
    if (zKP_client_debugging == true) then
        DKPMC:Print("[DEBUG] : "..msg)
    end
end

function DKPMC:PopUpMessage(message)
        
        getglobal("zKP_MessageFormLabelText"):SetText(message)
        getglobal("zKP_MessageForm"):Show()    
end


---------------------------------------------------------------
----------------- FRAME INITIALIZING METHODS ------------------
---------------------------------------------------------------

--[[ This function initialize the bidding frames columns and save the data in the global variable defined in 
     DKPManager client.toc ]]
function DKPMC:InitializeBiddingFrameColumns()
    column_cols =  {
                    {
                        ["name"] = "Player",
                        ["width"] = 120,
                        ["align"] = "LEFT",
                        ["bgcolor"] = { ["r"] = 0.0, ["g"] = 0.0, ["b"] = 0.0, ["a"] = 0.9 },
						["defaultsort"] = "dsc",

                    }, -- [1]
                    { 
                        ["name"] = "Bidding as", 
                        ["width"] = 70, 
                        ["align"] = "CENTER",
                        ["bgcolor"] = { ["r"] = 0.0, ["g"] = 0.0, ["b"] = 0.0, ["a"] = 0.4 },
						["defaultsort"] = "dsc",

                    }, -- [2]
                    { 
                        ["name"] = "Total DKP", 
                        ["width"] = 70, 
                        ["align"] = "CENTER",
                        ["bgcolor"] = { ["r"] = 0.0, ["g"] = 0.0, ["b"] = 0.0, ["a"] = 0.9 },
						["defaultsort"] = "dsc",

                    }, -- [3]
                   { 
                        ["name"] = "Bidding Spec", 
                        ["width"] = 70, 
                        ["align"] = "CENTER",
                        ["bgcolor"] = { ["r"] = 0.0, ["g"] = 0.0, ["b"] = 0.0, ["a"] = 0.4 },
						["defaultsort"] = "dsc",
                    }, -- [4]
                    { 
                        ["name"] = "Bid", 
                        ["width"] = 40, 
                        ["align"] = "RIGHT",
                        ["bgcolor"] = { ["r"] = 0.0, ["g"] = 0.0, ["b"] = 0.0, ["a"] = 0.9 },
						["defaultsort"] = "dsc",
                    }, -- [5]
                    
                }
    
    zKP_Client_Variables.biddingList.columns = column_cols    
end
--[[ This function initialize the bidding frame]]
function DKPMC:InitializeBiddingFrame(message)

    if (not zKP_Client_Variables.frame) then

        DKPMC:InitializeBiddingFrameColumns()

        local DKP_QueryList = getglobal("DKP_QueryList")
        if(DKP_QueryList) then
            tinsert(UISpecialFrames, DKP_QueryList)	  
        end

        zKP_Client_Variables.frame = DKP_QueryList
        highlight   = { ["r"] = 0.0, ["g"] = 0.0, ["b"] = 0.7, ["a"] = 0.5 }        
        numRows     = 8
        rowHeight   = 15

		zKP_Client_Variables.dkpList = ScrollingTable:CreateST(zKP_Client_Variables.biddingList.columns, numRows, rowHight, highlight, zKP_Client_Variables.frame)
		zKP_Client_Variables.dkpList.frame:SetPoint("BOTTOM", DKP_QueryList, "BOTTOM", 0, 7) -- must be set here since the default position is off. 
		
        zKP_Client_Variables.dkpList:RegisterEvents({
                                ["OnEnter"] = function (rowFrame, cellFrame, data, cols, row, realrow, column, ...)
														local bidder = nil 
														
														if (data ~= nil and realrow ~= nil and cols ~= nil) then	
															bidder = data[realrow].cols[1].value

															if (zKP_biddersItems[bidder] ~= nil) then	
																
																for index,item in ipairs(zKP_biddersItems[bidder]) do
				
																	if (#zKP_biddersItems[bidder] > 1 and GameTooltip:IsVisible() == 1) then																																		
																		zKP_client_second_weapon_tooltip:ClearLines()
																		zKP_client_second_weapon_tooltip:SetOwner(GameTooltip, "ANCHOR_PRESERVE")
																		zKP_client_second_weapon_tooltip:SetHyperlink(item)                                                        
																		zKP_client_second_weapon_tooltip:Show()																
																	else															
																		GameTooltip:SetOwner(getglobal("DKP_QueryList"), "ANCHOR_CURSOR")
																		GameTooltip:SetHyperlink(item)                                                        
																		GameTooltip:Show()
																	end
																end
															end
														end														
														
                                                    return false                                                                                                                                    
                                end,
                                ["OnLeave"] = function (rowFrame, cellFrame, data, cols, row, realrow, column, ...)	
									 GameTooltip:Hide()
									 zKP_client_second_weapon_tooltip:Hide()
									 return false
                                end,
                                
                            })
    end

    if (message ~= nil) then
        local cutMessageAt = string.find(message,"up") -2
        local item = string.sub(message,1,cutMessageAt)
    
        getglobal("DKP_QueryListTitleString"):SetText(GetAddOnMetadata("DKPManager_client", "Title").." Version: "..GetAddOnMetadata("DKPManager_client", "Version"))    
    
        getglobal("DKP_QueryListItemLinkText"):SetText(item)
    end

end

---------------------------------------------------------------
----------------------- Misc functions ------------------------
---------------------------------------------------------------

function DKPMC:IsPlayerInRaid(playerName)    
    local numRaidMembers = GetNumRaidMembers()
    local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML
    
        for	i=1, numRaidMembers  do
        name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
            
            name = string.lower(name)
            if (playerName ~= nil and string.find(name, playerName)) then
                return true
            end
        end	

    return false    
end

--[[ This function determines which color the bidder should have depending on which bidding rule he applies under]]
function DKPMC:DetermineBidColor(playerStatus)
    
    
    if ( playerStatus == "Trial Member" or playerStatus == "Less then 40%") then
        local returnStatement1 = { ["r"] = 1.0, ["g"] = 0.0, ["b"] = 0.0, ["a"] = 1.0 }   -- RED
        return returnStatement1

    elseif (playerStatus == "Member") then
        local returnStatement2 = { ["r"] = 0.0, ["g"] = 1.0, ["b"] = 0.0, ["a"] = 1.0 }   -- GREEN
        return returnStatement2
    elseif(playerStatus == "Alt" or playerStatus == "Casual" ) then
		return { ["r"] = 1.00, ["g"] = 0.96, ["b"] = 0.41, ["a"] = 1.0 }   --RETURNS YELLOW WHEN THE playerStatus IS AND ALT OR CASUAL 
	else
        return { ["r"] = 1.00, ["g"] = 1.00, ["b"] = 1.00, ["a"] = 1.0 }   --RETURNS WHITE WHEN THE playerStatus ISNT ONE OF THE ABOVE
    end
    
end

--[[ This function updates the raid roster information and query's for a DkpLeader.]]
function DKPMC:UpdateRaidRosterOnChange()

	DKPMC:QueryForDkpLeader()

    local numRaidMembers = GetNumRaidMembers()
    local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML
    for	i=1, numRaidMembers  do
        name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
        zKP_Client_Variables.raidRoster[name] = {}
        zKP_Client_Variables.raidRoster[name].name = name
        zKP_Client_Variables.raidRoster[name].class = class
        if (not online) then
            zKP_Client_Variables.raidRoster[name].online = "Offline"
        else
            zKP_Client_Variables.raidRoster[name].online = "Online"
        end
    end	

end

--[[ This function determines which color code should be used depending on which class the sender is.
 The information about the senders class is retrieved from the global variable defined in DKPManager client.toc file. ]]
function DKPMC:DetermineClassColor(playerNAME)
    
    local class = zKP_Client_Variables.raidRoster[playerNAME].class
    class = string.lower(class)


    if    (class == "shaman") then
        return { ["r"] = 0.14, ["g"] = 0.35, ["b"] = 1.0, ["a"] = 1.0 }    --SHAMAN 	        0.14, 0.35, 1.0, 1.0    - DARK BLUE
    elseif(class == "paladin") then
        return { ["r"] = 0.96, ["g"] = 0.55, ["b"] = 0.73, ["a"] = 1.0 }   --PALADIN           0.96, 0.55, 0.73, 1.0   - PINK
    elseif(class == "priest") then  
        return { ["r"] = 1.00, ["g"] = 1.00, ["b"] = 1.00, ["a"] = 1.0 }   --PRIEST 	        1.0 , 1.0 , 1.0, 1.0    - WHITE
    elseif(class == "rogue") then
        return { ["r"] = 1.00, ["g"] = 0.96, ["b"] = 0.41, ["a"] = 1.0 }   --ROGUE 	        1.0 , 0.96, 0.41, 1.0   - YELLOW
    elseif(class == "warrior") then
        return { ["r"] = 0.78, ["g"] = 0.61, ["b"] = 0.43, ["a"] = 1.0 }   --WARRIOR 		    0.78, 0.61, 0.43, 1.0   - BROWN
    elseif(class == "druid") then
        return { ["r"] = 1.00, ["g"] = 0.49, ["b"] = 0.04, ["a"] = 1.0 }   --DRUID 	        1.0 , 0.49, 0.04, 1.0   - ORANGE
    elseif(class == "hunter") then
        return { ["r"] = 0.67, ["g"] = 0.83, ["b"] = 0.45, ["a"] = 1.0 }   --HUNTER 	        0.67, 0.83, 0.45, 1.0   - GREEN
    elseif(class == "mage") then
        return { ["r"] = 0.41, ["g"] = 0.8 , ["b"] = 0.94, ["a"] = 1.0 }   --MAGE 	            0.41, 0.8 , 0.94, 1.0   - LIGHT BLUE
    elseif(class == "warlock") then
        return { ["r"] = 0.58, ["g"] = 0.51, ["b"] = 0.79, ["a"] = 1.0 }   --WARLOCK 	        0.58, 0.51, 0.79, 1.0   - PURPLE
    elseif(class == "death knight") then
        return { ["r"] = 0.77, ["g"] = 0.12, ["b"] = 0.23, ["a"] = 1.0 }   --DEATH KNIGHT 	    0.77, 0.12, 0.23, 1.0   - DARK RED
    else
        return { ["r"] = 1.00, ["g"] = 1.00, ["b"] = 1.00, ["a"] = 1.0 }   --RETURNS WHITE WHEN SENDERS CLASS DOSNT FIT THE IF CLAUSES
    end  
end

function DKPMC:RespondToOtherBiddersItemRequest(prefix, message, distribution, playerNAME)

    if( string.find(message, "return_item_to_be_replaced") ) then
        local auctionedItemLink = getglobal("DKP_QueryListItemLinkText"):GetText()
       
        local   itemName, 
                itemLink, 
                itemRarity, 
                itemLevel, 
                itemMinLevel, 
                itemType, 
                itemSubType, 
                itemStackCount,
                itemEquipLoc, 
                itemTexture = GetItemInfo(auctionedItemLink)

        local inventorySlotName = {}
        if (itemEquipLoc ~= nil) then
            inventorySlotName = DKPMC:ItemSlotConverter(itemEquipLoc)            
        end

		for index, slot in ipairs(inventorySlotName) do
			local item = GetInventoryItemLink("player",GetInventorySlotInfo(slot))
			if (item ~= nil) then	
				SendAddonMessage(zKP_Client_Prefix_bid_item_respond, item , "WHISPER" , playerNAME)				
			end			
		end	

    end
	
end

--[[Return the correct InventorySlotName from ItemEquipLoc's]]
function DKPMC:ItemSlotConverter(itemEquipLoc)

    if (itemEquipLoc == nil) then
        return {}
    end
    if(string.find(itemEquipLoc, "INVTYPE_AMMO")) then
       return {"AmmoSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_HEAD")) then
       return {"HeadSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_NECK")) then
       return {"NeckSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_SHOULDER")) then
       return {"ShoulderSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_BODY")) then
       return {"ShirtSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_CHEST")) then
       return {"ChestSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_ROBE")) then
       return {"ChestSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_WAIST")) then
       return {"WaistSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_LEG")) then
       return {"LegsSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_FEET")) then
       return {"FeetSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_WRIST")) then
       return {"WristSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_HAND")) then
       return {"HandsSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_FINGER")) then
       return {"Finger0Slot","Finger1Slot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_TRINKET")) then
       return {"Trinket0Slot","Trinket1Slot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_CLOAK")) then
       return {"BackSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_WEAPON")) then
       return {"MainHandSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_SHIELD")) then
       return {"SecondaryHandSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_2HWEAPON")) then
       return {"MainHandSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_WEAPONMAINHAND")) then
       return {"MainHandSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_WEAPONOFFHAND")) then
       return {"SecondaryHandSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_HOLDABLE")) then
       return {"SecondaryHandSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_RANGED")) then
       return {"RangedSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_THROWN")) then
       return {"RangedSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_RANGEDRIGHT")) then
       return {"RangedSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_RELIC")) then
       return {"RangedSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_TABARD")) then
       return {"TabardSlot"}
    end
    if(string.find(itemEquipLoc, "INVTYPE_TABARD")) then
       return {"TabardSlot"}
    end
    
    return {}
end

-- Replaces the value of the current zKP_Client_Variables.DkpLeader with the new zKP_Client_Variables.DkpLeader
function DKPMC:AddDkpLeader(playerNAME)
    zKP_Client_Variables.DkpLeader.name = string.lower(playerNAME)
    DKPMC:Debug("DkpLeader added - Leader: "..playerNAME)
end

--[[ This function updates the GuildRoster information, the same way you could do manually in WoW by opening 
     the Guild Tab frame where all your guildies names, ranks etc. is shown. 
     This Function is called before it is needed to retrieve information from the guild tab otherwise the information 
     from the guild tab would be eather, outdated or non existent]]
function DKPMC:UpdateGuildRoster()
    GuildRoster()
end


function DKPMC:FillColumnsWithData(playerNAME, bidAS, currentDKP, bidAMOUNT, biddingSPEC)

	  -- Init Columns --
        local zKP_Client_cols    = {}


        zKP_Client_cols[zKP_colsPlayerBidding]                  = {}
            zKP_Client_cols[zKP_colsPlayerBidding].value        = {}
            zKP_Client_cols[zKP_colsPlayerBidding].args         = nil
            zKP_Client_cols[zKP_colsPlayerBidding].color        = {}
            zKP_Client_cols[zKP_colsPlayerBidding].colorargs    = nil

        zKP_Client_cols[zKP_colsBiddingAs]                    = {}
            zKP_Client_cols[zKP_colsBiddingAs].value          = {}
            zKP_Client_cols[zKP_colsBiddingAs].args           = nil
            zKP_Client_cols[zKP_colsBiddingAs].color          = {}
            zKP_Client_cols[zKP_colsBiddingAs].colorargs      = nil

        zKP_Client_cols[zKP_colsCurrentDKP]                 = {}
            zKP_Client_cols[zKP_colsCurrentDKP].value       = {}
            zKP_Client_cols[zKP_colsCurrentDKP].args        = nil
            zKP_Client_cols[zKP_colsCurrentDKP].color       = {}
            zKP_Client_cols[zKP_colsCurrentDKP].colorargs   = nil

        zKP_Client_cols[zKP_colsBiddingSpec]                 = {}
            zKP_Client_cols[zKP_colsBiddingSpec].value       = {}
            zKP_Client_cols[zKP_colsBiddingSpec].args        = nil
            zKP_Client_cols[zKP_colsBiddingSpec].color       = {}
            zKP_Client_cols[zKP_colsBiddingSpec].colorargs   = nil
		
		zKP_Client_cols[zKP_colsBidAMOUNT]                 = {}
            zKP_Client_cols[zKP_colsBidAMOUNT].value       = {}
            zKP_Client_cols[zKP_colsBidAMOUNT].args        = nil
            zKP_Client_cols[zKP_colsBidAMOUNT].color       = {}
            zKP_Client_cols[zKP_colsBidAMOUNT].colorargs   = nil

        -- inserts the biding data into the columns --
        zKP_Client_cols[zKP_colsPlayerBidding].value        = playerNAME
            zKP_Client_cols[zKP_colsPlayerBidding].color    = DKPMC:DetermineClassColor(playerNAME)

        zKP_Client_cols[zKP_colsBiddingAs].value            = bidAS
            zKP_Client_cols[zKP_colsBiddingAs].color        = DKPMC:DetermineBidColor(bidAS)

        zKP_Client_cols[zKP_colsBiddingSpec].value          = biddingSPEC or zKP_Client_Variables.savedBids[playerNAME].biddingSPEC
            zKP_Client_cols[zKP_colsBiddingSpec].color      = zKP_whiteColor
    
        zKP_Client_cols[zKP_colsCurrentDKP].value           = currentDKP
            zKP_Client_cols[zKP_colsCurrentDKP].color       = zKP_whiteColor

		
		zKP_Client_cols[zKP_colsBidAMOUNT].value            = bidAMOUNT
            
			if (string.lower(bidAMOUNT) == "pass") then 
				zKP_Client_cols[zKP_colsBidAMOUNT].color = zKP_whiteColor 
			else 
				zKP_Client_cols[zKP_colsBidAMOUNT].color = zKP_greenColor 
			end 



    return zKP_Client_cols

end

function DKPMC:UpdateBiddingTable(playerNAME, bidAS, currentDKP, biddingSPEC, bidAMOUNT)

	biddingSPEC = biddingSPEC.." Spec"

	zKP_Client_Variables.savedBids[playerNAME].bidAS	   = bidAS
	zKP_Client_Variables.savedBids[playerNAME].currentDKP  = tonumber(currentDKP)
	zKP_Client_Variables.savedBids[playerNAME].biddingSPEC = biddingSPEC
	zKP_Client_Variables.savedBids[playerNAME].bidAMOUNT = tonumber(bidAMOUNT)
	
	for index, value in ipairs(zKP_Client_Variables.biddingList.data) do

		if (zKP_Client_Variables.biddingList.data[index].cols[zKP_colsPlayerBidding].value == playerNAME ) then
			zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBiddingAs].value  = bidAS
			zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBiddingAs].color	= DKPMC:DetermineBidColor(bidAS)
			
			zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBiddingSpec].value = zKP_Client_Variables.savedBids[playerNAME].biddingSPEC
			zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBiddingSpec].color = zKP_whiteColor

			zKP_Client_Variables.biddingList.data[index].cols[zKP_colsCurrentDKP].value = currentDKP
			zKP_Client_Variables.biddingList.data[index].cols[zKP_colsCurrentDKP].color = zKP_whiteColor

			zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBidAMOUNT].value = bidAMOUNT
		end
	end	
	zKP_Client_Variables.dkpList:Refresh()
end
-------------------------------------------------------------------
----------------------- DkpLeader functions -----------------------
-------------------------------------------------------------------

--[[ used to filter the different whispers comming from the DkpLeader.]]
function DKPMC:BiddersDataReceived(message)
    
    --[[ This if block is triggered when the DkpLeader returns with the information about a players Attendance and DKP.
         The rest of the bidding process is then continued.]]
    if ( message ~= nil and string.find(message,"<zKP>") and string.find(message,"DKP") and string.find(message,"Attendance") ) then 		

		-- Retrieves the players name from the message provided
		local playerNAME = string.sub(message,6,(string.find(message,"DKP") -2))    		

		if not (zKP_Client_Variables.savedBids[playerNAME]) then	
			zKP_Client_Variables.savedBids[playerNAME] = {}
		end
		
				-- Retrieves the players current DKP pool from the message provided
		zKP_Client_Variables.savedBids[playerNAME].currentDKP	= tonumber(string.sub(message,(string.find(message,"DKP") +4),(string.find(message,"Attendance") -3))) 
				-- Retrieves the status the player is bidding as
		zKP_Client_Variables.savedBids[playerNAME].bidAS		= DKPMC:PlayerBidAs(message,playerNAME)		

		if (playerNAME == zKP_addonOwner) then	
			zKP_Client_Variables.savedBids[playerNAME].biddingSPEC = getglobal("DKP_QueryListButtonBiddingSpec"):GetText()
		end

		if not (zKP_Client_Variables.savedBids[playerNAME].bidAMOUNT) then				
			DKPMC:Debug("zKP_Client_Variables.savedBids[playerNAME].bidAMOUNT = "..zKP_Client_Variables.savedBids[playerNAME].bidAMOUNT)
			bidAMOUNT	= 0
		elseif (zKP_Client_Variables.savedBids[playerNAME].bidAMOUNT > zKP_Client_Variables.savedBids[playerNAME].currentDKP) then	
					-- the bidding players saved bid		
				zKP_Client_Variables.savedBids[playerNAME].bidAMOUNT  = zKP_Client_Variables.savedBids[playerNAME].currentDKP
			end
						
		DKPMC:UpdateBiddingTable(playerNAME, -- players name
								 zKP_Client_Variables.savedBids[playerNAME].bidAS, -- player bid as e.g "Trial Member"/"Member"/"Less then 40%"
								 zKP_Client_Variables.savedBids[playerNAME].currentDKP,  -- player has X DKP
								 zKP_Client_Variables.savedBids[playerNAME].biddingSPEC,
								 zKP_Client_Variables.savedBids[playerNAME].bidAMOUNT -- player bid X amount
								)
	else
		DKPMC:Print("Invalid data received from DKP Server \n"..message)
	end
end


-- Sends a message to the DKPLeader who is handling the DKP
function DKPMC:QueryToDkpLeader(message)  

	if (zKP_Client_Variables.DkpLeader.name ~= nil and zKP_Client_Variables.DkpLeader.name ~= "") then	
		SendAddonMessage(zKP_Client_Prefix, message, "WHISPER"    , zKP_Client_Variables.DkpLeader.name)
	end
	            
end

function DKPMC:QueryForDkpLeader()
	if (zKP_Client_Variables.DkpLeader.name ~= nil and zKP_Client_Variables.DkpLeader.name == "") then	
		SendAddonMessage(zKP_Client_Prefix, "DkpLeader", "GUILD",nil)
	end
end
-- Retrieves the players attendance from the message provided and figures which status the player can 
-- Bid under, e.g. Trial Member, Member or if attendance is below 40% he bids as "Less then 40%"
function DKPMC:PlayerBidAs(message, bidder)

    
    local numGuildMembers = GetNumGuildMembers()
    local name, level, class, zone, group, online, note, officernote
    
    
    for	i=1, numGuildMembers  do
        note = "" officernote = ""
        name, rank, rankIndex, level, class, zone, group, note, officernote, online = GetGuildRosterInfo(i)
    
        
        
        if ( string.find(rank,"^Member$") or string.find(rank,"^Class Leader$") or string.find(rank,"^Officer$") or  string.find(rank,"^Class/Raid Lead$") ) then 
            name, rank, rankIndex, level, class, zone, group, note, officernote, online = GetGuildRosterInfo(i)


            if( string.find(name , bidder) ) then     
                local attendanceCut = string.len(message)
                    messageCut = string.sub(message,(attendanceCut -4),(attendanceCut-1) )
                    message = messageCut
                    messageCut = string.find(message,"%d")
                    message = string.sub(message,messageCut,string.len(message))
                
                local attendance = tonumber( message )
    
                if (attendance < 40) then
                    return "Less then 40%"
                else
                    return "Member"
                end                
            end
        elseif( string.find(name , bidder) ) then     
            return rank
        end 
    end	 
end




-----------------------------------------------------------------
----------------------- Bidding functions -----------------------
-----------------------------------------------------------------

--[[This function makes a bid in raid channel as long as the bidding isnt closed]]
function DKPMC:MakeAbid(bid, addToHighestBid)
    
    if(zKP_Client_Variables.bidding == true and bid ~= nil) then
		local message = ""

		
		if (zKP_Client_Variables.savedBids[zKP_addonOwner] ~= nil and zKP_Client_Variables.savedBids[zKP_addonOwner].currentDKP ~= nil) then	
			bid = DKPMC:BiddingRule(zKP_addonOwner, zKP_Client_Variables.savedBids[zKP_addonOwner].currentDKP, bid )
		else
			bid = DKPMC:BiddingRule(zKP_addonOwner, "Waiting", bid )
		end

		if (addToHighestBid == nil) then	
			addToHighestBid = false
		end

        if (tonumber(bid) > 0 ) then

			if (addToHighestBid == true) then					
				message = "bid "..(zKP_highestBid + tonumber(bid))
			elseif (bid > zKP_highestBid) then
				message = "bid "..bid				
			else
				DKPMC:PopUpMessage("You can not bid lower \nthen highest bid")	
			end
			
            SendChatMessage(message, "RAID",nil,nil)
			getglobal("DKP_QueryListButtonBiddingSpec"):Enable()			
		end
    else
        DKPMC:PopUpMessage("Bidding closed, you can not bid")
    end
    
    getglobal("DKP_QueryListBidAmount"):SetText("")
    getglobal("DKP_QueryListBidAmount"):ClearFocus() 

end
--[[ This function is called when the DkpLeader has initiated a bidding round ]]
function DKPMC:BiddingStart(message, playerNAME)
	--DKPMC:QueryToDkpLeader("dkp "..zKP_addonOwner)
	DKPMC:Debug("remember to add DKPMC:QueryToDkpLeader(dkp..zKP_addonOwner)")

	DKPMC:UpdateRaidRosterOnChange()  -- makes sure that the raidRoster info is up to date before bidding starts
	DKPMC:UpdateGuildRoster()  -- makes sure that the guildRoster is up to date before bidding starts
    
    -- Reset biddingList setup--
    zKP_Client_Variables.biddingList         = {}
    zKP_Client_Variables.biddingList.columns = {}
    zKP_Client_Variables.biddingList.data    = {}

    zKP_Client_Variables.bidding = true

    DKPMC:InitializeBiddingFrame(message)
    
    zKP_Client_Variables.dkpList:SetData(zKP_Client_Variables.biddingList.data)
	getglobal("DKP_QueryListButtonPass"         ):Enable()
    getglobal("DKP_QueryListButtonBid"          ):Enable()
    getglobal("DKP_QueryListButtonBidOne"       ):Enable()
    getglobal("DKP_QueryListButtonBidTwo"       ):Enable()
    getglobal("DKP_QueryListButtonBidThree"     ):Enable()
	getglobal("DKP_QueryListButtonBiddingSpec"	):Enable()
	getglobal("DKP_QueryListButtonBiddingSpec"	):SetText("Main")
	if (InCombatLockdown() == 1) then	
		if ( zKP_Client_Variables.options.gui.showBidDialogInCombat == true) then	
			zKP_Client_Variables.frame:Show() 
		end
	else
		zKP_Client_Variables.frame:Show() 
	end
    
end

--[[ This function is called when a bidding round has started and someone has made a bid]]
function DKPMC:BidRecieved(message, bidder)

    if (zKP_biddersItems[bidder] == nil) then                                                 
        SendAddonMessage(zKP_Client_Prefix_bid_item_query, "return_item_to_be_replaced", "WHISPER", bidder)
    end

    --saves the bid that the sender has bid on the item "bid xx"
    message = string.sub(message,5, string.len(message) )
	
	DKPMC:RegisterBid(bidder, --playerNAME
					  nil, --bidAS
					  nil, --currentDKP
					  tonumber(message) --the bid value after it has been concatenated
					 )

	--[[ Queary the DkpLeader for the dkp of the bidder, the response will be cought in a WHISPER event - 
         see function whisperRecieved(zKP_Client_message,sender).]]
	if (zKP_Client_Variables.savedBids[bidder].currentDKP == "Waiting" or zKP_Client_Variables.savedBids[bidder].currentDKP == nil) then	
		DKPMC:QueryToDkpLeader("dkp "..bidder)
	end		
end

function DKPMC:BiddingRule(playerNAME, currentDKP, bidAMOUNT )
		bidAMOUNT = tonumber(bidAMOUNT)

		-- if the bid is higher then the bidders current dkp pool, the value of the currentDKP is returned
		if (type(currentDKP) == "number") then	
			if (tonumber(bidAMOUNT) > currentDKP) then
				DKPMC:Debug("change bid")
				return currentDKP 
			else
				DKPMC:Debug("Dont change bid")
				return bidAMOUNT
			end
		else
			DKPMC:Debug("currentDKP was not a number type = "..type(currentDKP))
			return bidAMOUNT
		end		
		
end

--[[ This function is called when the DkpLeader has announced that the bidding round is over]]
function DKPMC:BiddingClosed()
    zKP_highestBid                      = 0
    zKP_Client_Variables.bidding    = false
    zKP_Client_Variables.savedBids  = {}

    zKP_biddersItems = {}
    
    getglobal("DKP_QueryListButtonPass"         ):Disable()
    getglobal("DKP_QueryListButtonBid"          ):Disable()
    getglobal("DKP_QueryListButtonBidOne"       ):Disable()
    getglobal("DKP_QueryListButtonBidTwo"       ):Disable()
    getglobal("DKP_QueryListButtonBidThree"     ):Disable()
	getglobal("DKP_QueryListButtonBiddingSpec"	):Disable()

        
        
end
--[[ This function is used when the "Pass on item" button is called, it will send a msg to the raid that the item is of 
     of no interest to the bidder]]
function DKPMC:PassOnItem(playerNAME)
		if (DKPMC:PassedOnItem(playerNAME) == true) then	
			SendChatMessage("Pass","RAID",nil,nil)        
		end
		
end

function DKPMC:PassedOnItem(playerNAME) 
    local playerFound = false
	
        for index, value in ipairs(zKP_Client_Variables.biddingList.data) do
			comparedPlayer = zKP_Client_Variables.biddingList.data[index].cols[zKP_colsPlayerBidding].value

	            --If the bidder is the highest bidder set color green
--[[            if ( tonumber(zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBidAMOUNT].value) == zKP_highestBid ) then
                zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBidAMOUNT].color = zKP_greenColor     
            else
                zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBidAMOUNT].color = zKP_whiteColor                       
            end]]

				--found set playerFound variable to true.
			if (comparedPlayer == playerNAME ) then
				playerFound = true

					--stops the playerNAME from passing if playerNAME is highest 
				if (tonumber(zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBidAMOUNT].value) == tonumber(zKP_highestBid) and tonumber(zKP_highestBid) > 0) then
						--give warning if playerNAME is running the addon
					if (playerNAME == zKP_addonOwner) then
						DKPMC:PopUpMessage("You can not pass on item \nbecause you are the highest bidder")							
					end
				elseif (string.find(string.lower(zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBidAMOUNT].value), "pass") == nil) then					
					zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBidAMOUNT].value = "Pass ("..zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBidAMOUNT].value..")"
                    zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBidAMOUNT].color = zKP_whiteColor                                           					
					zKP_Client_Variables.dkpList:Refresh()		
					getglobal("DKP_QueryListButtonBiddingSpec"):Disable()
				end  				
            end
        end
		
		if (playerFound == false) then
			local dataIndex = #(zKP_Client_Variables.biddingList.data)
					dataIndex = dataIndex +1
			
			zKP_Client_Variables.biddingList.data[dataIndex]             = {}
			zKP_Client_Variables.biddingList.data[dataIndex].color       = {}
			zKP_Client_Variables.biddingList.data[dataIndex].colorargs   = {}        
			zKP_Client_Variables.biddingList.data[dataIndex].cols        = DKPMC:FillColumnsWithData(playerNAME, "Pass", "Pass", "Pass", "Waiting")
			zKP_Client_Variables.dkpList:SetData(zKP_Client_Variables.biddingList.data)			
			getglobal("DKP_QueryListButtonBiddingSpec"):Disable()
		end

		if (playerFound == true) then	
			return false
		else
			return true -- small HACK made until a solution for DKPMC:PassOnItem(playerNAME) is made. Dosnt make sense that a pass is only registrered after the addonOwner sends it.
		end
end

-- Used to register all bids 
function DKPMC:RegisterBid(playerNAME, bidAS, currentDKP, bidAMOUNT)

	--If its a new bidder then create entry to savedBids
    if (zKP_Client_Variables.savedBids[playerNAME] == nil) then	
		zKP_Client_Variables.savedBids[playerNAME] = {}
		zKP_Client_Variables.savedBids[playerNAME].currentDKP	= "Waiting"
		zKP_Client_Variables.savedBids[playerNAME].bidAS		= "Waiting"
		zKP_Client_Variables.savedBids[playerNAME].biddingSPEC	= "Waiting"
		zKP_Client_Variables.savedBids[playerNAME].bidAMOUNT	= tonumber(bidAMOUNT)
		DKPMC:QueryBidderForBiddingSpec(playerNAME)
	
	elseif (bidAS ~= nil and bidAMOUNT ~= nil) then	
			zKP_Client_Variables.savedBids[playerNAME].bidAS	   = bidAS
			zKP_Client_Variables.savedBids[playerNAME].currentDKP  = tonumber(currentDKP)
	end

		--Save bidders data in savedBids
		zKP_Client_Variables.savedBids[playerNAME].bidAMOUNT   = DKPMC:BiddingRule(playerNAME, zKP_Client_Variables.savedBids[playerNAME].currentDKP, bidAMOUNT )	

  DKPMC:AddBidderToScrollingTable(playerNAME, -- players name
						zKP_Client_Variables.savedBids[playerNAME].bidAS, -- player bid as e.g "Trial Member"/"Member"/"Less then 40%"
						zKP_Client_Variables.savedBids[playerNAME].currentDKP,  -- player has X DKP
						zKP_Client_Variables.savedBids[playerNAME].bidAMOUNT -- player bid X amount
						) 

end

--[[ This function is called to add the bidder's data to the bidding frame]]
function DKPMC:AddBidderToScrollingTable(playerNAME, bidAS, currentDKP, bidAMOUNT)
        
        local playerRegistered = false
        local comparedPlayer = "empty"
        
        if ( bidAMOUNT > zKP_highestBid ) then
            zKP_highestBid = bidAMOUNT
			zKP_biggerThenHighestBid = true
			for  index, value in ipairs(zKP_Client_Variables.biddingList.data) do
				comparedPlayer = zKP_Client_Variables.biddingList.data[index].cols[zKP_colsPlayerBidding].value
								 zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBidAMOUNT].color = zKP_whiteColor

				--This if block is triggered if the player has bidded before and is found. Thereby updating the bidders lastBid value 
				if (string.find(comparedPlayer, playerNAME) ) then
				
					--If the player has passed ealier in the bidding round and his bidAMOUNT value is changed, then the players bidAMOUNT value is changed back to his old bid value
					if( string.find(zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBidAMOUNT].value,"Pass") ) then
						zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBidAMOUNT].value = string.sub(zKP_Client_Variables.biddingList.data[index].cols[zKP_colsBidAMOUNT].value,7,-2)
					end
						
					zKP_Client_Variables.biddingList.data[index].cols = DKPMC:FillColumnsWithData(playerNAME, bidAS, currentDKP, bidAMOUNT)
					playerRegistered = true
				end
			end
        else
            zKP_biggerThenHighestBid = false
        end

        --This function is called if player is not in the scrolling table
        if (playerRegistered == false and zKP_biggerThenHighestBid == true ) then
            index = #(zKP_Client_Variables.biddingList.data) +1

            -- color, colorargs and the columns to the bidding data --
            zKP_Client_Variables.biddingList.data[index]             = {}
            zKP_Client_Variables.biddingList.data[index].cols        = DKPMC:FillColumnsWithData(playerNAME, bidAS, currentDKP, bidAMOUNT)
            zKP_Client_Variables.biddingList.data[index].color       = {}
            zKP_Client_Variables.biddingList.data[index].colorargs   = {}
        end

    ------------------------ DONE -------------------------------

    zKP_Client_Variables.dkpList:SetData(zKP_Client_Variables.biddingList.data)
	zKP_Client_Variables.dkpList:SortData()
end



-------------------------------------------------------------
------------------------ HANDLERS ---------------------------
-------------------------------------------------------------


--[[ 
	This function routes the events called when changes to the raid is made.
		* event - the event type fired (string - CHAT_MSG_ADDON)
		* prefix - The prefix declared from SendAddonMessage. (string)
		* message - The message from SendAddonMessage. (string)
		* channel - The message channel used for this message. Possible values include PARTY, RAID, GUILD, BATTLEGROUND, or WHISPER. (string)
		* sender - The username of the sender. (string) 	
	]]
function DKPMC:RaidEventHandler(event, prefix, message, channel, playerNAME)
	DKPMC:TimerEvent(event, message, playerNAME)
end

--[[ Is called when a biddingEvent is called - See OnEnable() for Events registered to this handler
		* event - the event type fired (string - CHAT_MSG_WHISPER)
		* prefix - The prefix declared from SendAddonMessage. (string)
		* message - The message from SendAddonMessage. (string)
		* channel - The message channel used for this message. Possible values include PARTY, RAID, GUILD, BATTLEGROUND, or WHISPER. (string)
		* sender - The username of the sender. (string) 
]]
function DKPMC:BiddingEvent(event, message, playerNAME)
    
    if (event == "CHAT_MSG_RAID" or event == "CHAT_MSG_RAID_LEADER" or event == "CHAT_MSG_RAID_WARNING" and message ~= nil) then

        if ( string.lower(message) == "pass" and zKP_addonOwner ~= playerNAME) then  -- small hack that ignore pass from the addonOwner him self in order to fix the bad design in DKPMC:PassedOnItem and DKPMC:PassOnItem(playerNAME)
			if(zKP_Client_Variables.bidding) then   
				DKPMC:PassedOnItem(playerNAME)
			end                
        else
			DKPMC:BiddingDecider(message, playerNAME)
        end
    end
end


--[[ This function is called to determine what action of course to take depending on which message was written in RAID chat]]
function DKPMC:BiddingDecider(message, playerNAME)  

        local lowerCaseMessage = string.lower(message)
    
        if( string.find(lowerCaseMessage, "^bid (%d+)$")) then
			DKPMC:BidRecieved(message, playerNAME)

			elseif (string.find(message, "(.+) up for bids")) then  -- uses message because string.lower() ruins ItemLinks from chat.
				DKPMC:BiddingStart(message,playerNAME)  -- Opens the Bidding and initializing of the Bidding frame.

            elseif( string.find(message,"Bidding closed on (.+)") or string.find(message,"(.+) has won (.+) for (.+) DKP!") or string.find(message, "No bids received on (.+) Going to dusting.") ) then
                    DKPMC:BiddingClosed()
                end
end


-------------------------------------------------------------
---------------- ADDON COMMUNICATION METHODS ----------------
-------------------------------------------------------------

-------- Received messages --------

--[[this method is called when the DKP Server is sending information via ADDON messages]]
function DKPMC:Server_Client_Syncronization(prefix, message, distribution, playerNAME)
		
		if(prefix == zKP_Server_Prefix and string.find(message, "DkpLeader") and zKP_Client_Variables.DkpLeader.name == "" ) then

			DKPMC:AddDkpLeader(playerNAME)
		elseif(message ~= "DkpLeader" ) then
			DKPMC:BiddersDataReceived(message)        
		end

end

--[[ This function receives and store the item data other bidders wear, when it is send via ADDON messages ]]
function DKPMC:BiddersItemDataReceived(prefix, message, distribution, playerNAME)

    if(string.find(message, "^|c%x+|H(.+)|h%[.+%]") )  then           
      
        if(zKP_biddersItems[playerNAME] == nil) then
            zKP_biddersItems[playerNAME] = {}
            zKP_biddersItems[playerNAME][1] = message
        else
            zKP_biddersItems[playerNAME][2] = message              
        end
    end
end

function DKPMC:BidderChangingBiddingSpec(prefix, message, distribution, playerNAME)

	if (message == zKP_MainSpec or message == zKP_OffSpec or zKP_DualSpec) then	

		DKPMC:UpdateBiddingTable(playerNAME, -- players name
								 zKP_Client_Variables.savedBids[playerNAME].bidAS, -- player bid as e.g "Trial Member"/"Member"/"Less then 40%"
								 zKP_Client_Variables.savedBids[playerNAME].currentDKP,  -- player has X DKP
								 message, -- bidding spec
								 zKP_Client_Variables.savedBids[playerNAME].bidAMOUNT -- player bid X amount
								)
	else 
		DKPMC:Debug("invalid data received from DKP server: msg - "..message)
	end
end


------- Send messages ---------

function DKPMC:SendChangeBiddingSpecNotice(biddingSPEC)

	if (zKP_Client_Variables.bidding == true) then	
		if (zKP_Client_Variables.savedBids[zKP_addonOwner] ~= nil) then	
			DKPMC:SendCommMessage(zKP_Client_Prefix_ChangeBiddingSpec, biddingSPEC, "RAID")
		end		
	end
end

function DKPMC:SendResponseForBiddingSpec(biddingSPEC)

	if (zKP_Client_Variables.bidding == true) then	
		if (zKP_Client_Variables.savedBids[zKP_addonOwner] ~= nil) then	
			DKPMC:SendCommMessage(zKP_Client_Prefix_ChangeBiddingSpec, biddingSPEC, "RAID")
		end		
	end
end


function DKPMC:QueryBidderForBiddingSpec(playerNAME)
		if (zKP_Client_Variables.bidding == true) then	
			DKPMC:SendCommMessage(zKP_Client_Prefix_QueryBiddingSpec, getglobal("DKP_QueryListButtonBiddingSpec"):GetText(), "WHISPER",playerNAME)
		end
end

-------------------------------------------------------------
-------------------- EVENT METHOD WRAPPERS ------------------
-------------------------------------------------------------

function DKPMC:TimerEvent(event, message, playerNAME)
	DKPMCwlEngine:TimerEvent(event, message, playerNAME)
end
